package com.xueyi.aixihu.controller;

import com.xueyi.aixihu.config.SpringContextConfig;
import com.xueyi.aixihu.controller.base.BaseController;
import com.xueyi.aixihu.entity.generatedMapper.AxhFinanceMapper;
import com.xueyi.aixihu.entity.po.AxhFinance;
import com.xueyi.aixihu.exception.SzException;
import com.xueyi.aixihu.pattern.FinanceReportAuditProcessDirector;
import com.xueyi.aixihu.response.base.BaseResponse;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述
 * @author 刘梓江
 */
@RestController
public class FinanceReportAuditProcessController  extends BaseController {

    /**
     * 报表提交
     * @param contentId
     * @return
     */
    @RequestMapping("/financeReport/reportSubmit/{contentId}")
    public BaseResponse<Object> reportSubmit(@PathVariable Integer contentId)throws SzException {
        AxhFinance axhFinance = SpringContextConfig.getBean(AxhFinanceMapper.class).selectByPrimaryKey(contentId);
        //报表审核操作
        FinanceReportAuditProcessDirector financeReportAuditProcessDirector=new FinanceReportAuditProcessDirector(axhFinance);
        financeReportAuditProcessDirector.submit();
        return BaseResponse.success(axhFinance);
    }

    /**
     * 报表审核同意
     * @param contentId
     * @return
     */
    @RequestMapping("/financeReport/passed/{contentId}")
    public BaseResponse<Object> passed(@PathVariable Integer contentId)throws SzException {
        AxhFinance axhFinance = SpringContextConfig.getBean(AxhFinanceMapper.class).selectByPrimaryKey(contentId);
        //报表审核操作
        FinanceReportAuditProcessDirector financeReportAuditProcessDirector=new FinanceReportAuditProcessDirector(axhFinance);
        financeReportAuditProcessDirector.passed();
        return BaseResponse.success(axhFinance);
    }

    /**
     * 报表审核拒绝
     * @param contentId
     * @return
     */
    @RequestMapping("/financeReport/dismiss/{contentId}/{dismissDesc}")
    public BaseResponse<Object> dismiss(@PathVariable Integer contentId,@PathVariable String dismissDesc)throws SzException {
        AxhFinance axhFinance = SpringContextConfig.getBean(AxhFinanceMapper.class).selectByPrimaryKey(contentId);
        //报表审核操作
        FinanceReportAuditProcessDirector financeReportAuditProcessDirector=new FinanceReportAuditProcessDirector(axhFinance);
        financeReportAuditProcessDirector.dismiss(dismissDesc);
        return BaseResponse.success(axhFinance);
    }

    /**
     * 报表发布
     * @param contentId
     * @return
     */
    @RequestMapping("/financeReport/release/{contentId}")
    public BaseResponse<Object> release(@PathVariable Integer contentId)throws SzException {
        AxhFinance axhFinance = SpringContextConfig.getBean(AxhFinanceMapper.class).selectByPrimaryKey(contentId);
        //报表审核操作
        FinanceReportAuditProcessDirector financeReportAuditProcessDirector=new FinanceReportAuditProcessDirector(axhFinance);
        financeReportAuditProcessDirector.release();
        return BaseResponse.success(axhFinance);
    }
}
